import pymysql

try:
    connection=pymysql.connect(
        host="192.168.21.130",
        port=3306,
        user="python",
        passwd="python",
        db="python",
        charset="utf8")
    cursor_test=connection.cursor()
    # 插入语句
    # sql="insert into students(name) values(%s)"
    # 修改语句
    # sql="update students set name=%s where id=9"
    # 删除语句
    sql = "delete from students where id=11"
    cursor_test.execute(sql)
    connection.commit()

    cursor_test.close()
    connection.close()
    print("OK")
except Exception as error:
    print("下面是异常信息：")
    print(error)